// pages/collection/collection.js
var app = getApp()

Page({

  /**
   * 页面的初始数据
   */
  data: {
    show:true

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(app.globalData.pager)
    console.log(app.globalData.pagel)
    var that = this
    wx: wx.request({
      url: app.globalData.url + '/v1/Strategy/listStrategy?page=' + app.globalData.pager + "&size=" + 2,
      data: {
      },
      header: {
      },
      method: 'GET',
      dataType: 'json',
      responseType: 'text',
      success: function (res) {
        console.log(res.data.data.data)
        that.setData({
          list: res.data.data.data
        })
        console.log(that.data.list)

      },
      fail: function (res) {
        console.log(res)
      },
      complete: function (res) { },
    })
    wx: wx.request({
      url: app.globalData.url + '/v1/Strategy/listStrategy?page=' + app.globalData.pagel + "&size=" + 2,
      data: {},
      header: {},
      method: 'GET',
      dataType: 'json',
      responseType: 'text',
      success: function (res) {
        console.log(res.data.data.data)
        that.setData({
          listr: res.data.data.data
        })
      },
      fail: function (res) {
        console.log(res)
      },
      complete: function (res) { },
    })

  },

  //打开对应id的详细游记内容
  content_item: function (e) {
    var that = this
    var content_list
    var sid = e.currentTarget.id
    console.log("游记id为：" + sid)
    wx: wx.request({
      url: app.globalData.url + '/v1/Strategy/getStrategyDetail?sid=' + sid,
      data: '',
      header: {},
      method: 'GET',
      dataType: 'json',
      responseType: 'text',
      success: function (res) {
        console.log(res.data.data)
        that.setData({
          list_item: res.data.data
        })
        app.globalData.content_item = that.data.list_item
        var item = JSON.stringify(app.globalData.content_item);
        // console.log("转换游记内容:" + item)
        wx.navigateTo({
          url: '../content/content'
        })
      },
      fail: function (res) { },
      complete: function (res) { },
    })

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var that = this
    console.log(app.globalData.alltoken)
    if (app.globalData.alltoken != null) {
      that.setData({
        show: false
      })
    }
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})